import  React , { lazy } from "react";
import { useRoutes , Navigate} from "react-router-dom";
import Login from '../views/Login/Login';
import Home from '../views/Home/Home';
import Layout from '../components/layout/index'
import Go from '../views/Go/Go'

const  Room  = lazy(() => import('../views/Room/Room'));
const  Build  = lazy(() => import('../views/Build/Build'));
const  RoomList = lazy(()=> import('../views/Roomlist/Roomlist'))

// 独立页面
const frameOut = [
  { path: '/login', element: <Login />  },
  { path: '/go', element: <Go />}
]



// 功能页面
const frameIn = [
    { path: 'index', element: <Home /> } ,
    { path: 'setroom', element: <Room /> },
    { path: 'setbuild', element: <Build /> },
    { path:'roomlist',element: <RoomList /> },
    { path: '*', element: <Navigate to="/index" /> }
]



const Router = ()=>{


  let element = useRoutes([
    ...frameOut,
    { path: '/', element: <Navigate to="/index" /> }, // 进入到首页的话 就重定向到 /index
    { path: "/*", element: <Layout /> , children: frameIn},  
    

  ]);
  return element

}

export default Router;





